package Operations;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        //归还图书
        System.out.println("归还图书！");
        System.out.println("请输入你要归还图书的名字：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        int size = bookList.getNumBook();
        for (int i = 0; i < size; i++) {
            Book book = bookList.getpos(i);
            if(name.equals(book.getBookname()))
            {
                book.setBorrow(false);
                System.out.println("归还图书成功！");
                return;
            }
        }
        System.out.println("图书不需要归还！");
    }
}
